﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using StripboekManager.Contract.Command;
using CBM.Contract.Implementation.Entities;
using Caliburn.Micro;
using Microsoft.Practices.Unity;
using StripboekManager.Contract.ViewModel;

namespace StripboekManager.Contract.Implementation.Command
{
    public class CBMCommand : PropertyChangedBase, ICBMCommand
    {
        [InjectionConstructor]
        public CBMCommand()
        {

        }

        public CBMCommand(string name, string caption)
        {

        }

        private string nameField;
        public string Name
        {
            get
            {
                return nameField;
            }
            set
            {
                nameField = value;
                base.NotifyOfPropertyChange("Name");
            }
        }

        private string captionField;
        public string Caption
        {
            get
            {
                return captionField;
            }
            set
            {
                captionField = value;
                base.NotifyOfPropertyChange("Caption");
            }
        }


        Action<object> executeField = null;

        public bool CanExecute(object parameter)
        {
            return parameter!=null&&executeField != null;              
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            executeField.Invoke(parameter);
        }


        private IViewModel viewModelField;
        public IViewModel GetView()
        {
            return viewModelField;
        }
    }
}
